	PROGRAM ADDTEST
	INTEGER OBS,BSO,VAR
	DIMENSION DAT(50,5)
	CHARACTER*4 YEAR
	CHARACTER*1 ANS
	CHARACTER*114 A,B,C,D
	CHARACTER*23 TIT(50)
	OPEN(UNIT=3,CARRIAGECONTROL='LIST',STATUS='UNKNOWN')
C
	J=1
11	FORMAT(1X,A,3X,A,5F11.0)
501	READ(2,11,END=500)YEAR,TIT(J),(DAT(J,K),K=1,5)
	J=J+1
	GO TO 501
500	J=J-1	
C
	WRITE(6,14)
14	FORMAT(' TO ADD DATA TO HISTORICAL DATA FILE ENTER AN <A>'/
	1' TO CHANGE DATA FOR A SINGLE YEAR ENTER A <C>'/,' ENTER>',$)
	READ(5,15)ANS
C
15	FORMAT(A)
40	READ(1,10,END=200)A
10	FORMAT(A)
	WRITE(3,10)A
	READ(1,10)B
        DECODE(1,22,B(3:3))VAR
22   	FORMAT(I1)
        DECODE(2,20,B(8:9))OBS
	BSO=OBS+1
20	FORMAT(I2)
   	IF(ANS.EQ.'A')ENCODE(2,21,B(8:9))BSO
21 	FORMAT(I2)
	WRITE(3,10)B
	READ(1,10)C
	WRITE(3,10)C
	NSKIP=110-VAR*9
C
	IF(ANS.EQ.'A')THEN
		DO 30 I=1,OBS
		READ(1,10)D
		WRITE(3,10)D
30		CONTINUE
		DO 31 M=1,J
		IF(C(1:20).EQ.TIT(M)(1:20))THEN
			WRITE(3,12)(DAT(M,I),I=1,VAR),YEAR
			WRITE(7,13)TIT(M),(DAT(M,I),I=1,VAR),YEAR
13			FORMAT(1X,A,1X,<VAR>F9.2,2X,A)
		END IF
31		CONTINUE
12 		FORMAT(<VAR>F9.2,<NSKIP>X,A)
		GO TO 40
	ELSE IF(ANS.EQ.'C')THEN
		DO 32 I=1,OBS
		READ(1,10)D
		DO 31 M=1,J
		IF(D(111:114).EQ.YEAR)THEN
			DO 33 M=1,J
			IF(C(1:20).EQ.TIT(M)(1:20))THEN
				WRITE(3,12)(DAT(M,K),K=1,VAR),YEAR
				WRITE(7,13)TIT(M),(DAT(M,K),K=1,VAR),YEAR
			END IF
33			CONTINUE
		END IF	
	END IF
200	STOP
	END
